package ius.mantianx.dao;

import ius.mantianx.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @author starrysky
 * @title: DepartmentDao
 * @projectName rev_thymeleaf_boot
 * @description: dao layer
 * @date 2021/2/802:12
 */
@Repository
public class DepartmentDao {

    /**
     * 模拟数据
     */
    private static Map<Integer, Department> departments = null;

    static {
        departments = new HashMap<>(16, 0.75F);

        departments.put(101, new Department(101, "教学部"));
        departments.put(102, new Department(102, "市场部"));
        departments.put(103, new Department(103, "教研部"));
        departments.put(104, new Department(104, "运营部"));
        departments.put(105, new Department(105, "后勤部"));
    }

    /**
     * 获取所有部门信息
     *
     * @return
     */
    public Collection<Department> getDepartments() {
        return departments.values();

    }

    /**
     * 根据id获取部门信息
     * @param id
     * @return
     */
    public Department getDepartmentById(Integer id){
        return departments.get(id);
    }
}
